<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 300px;
        background-color: thistle;
        position: absolute;
        margin: 0px;
        left: 0px;
      }
    </style>
  </head>
  <body>
    <div class="box"></div>
    <script>
      var boxEle = document.querySelector(".box");
      boxEle.style.display = "none";
      document.onclick = function (e) {
        var e = e || window.e;
        boxEle.style.marginLeft = `${e.clientX}px`;
        boxEle.style.marginTop = `${e.clientY}px`;
        boxEle.innerHTML = `${e.clientX}px,${e.clientY}px`;
        boxEle.style.display = "none";
        document.oncontextmenu = function () {
          boxEle.style.display = "block";
        };
      };
    </script>
  </body>
</html>
